package cn.maxhou.mapper;

import cn.maxhou.entity.Supplier;
import cn.maxhou.service.Supplierervice;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Arrays;
import java.util.List;

class SupplierMapperTest3 {

    @Test
    public void selectAll() {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext3.xml");
        Supplierervice supplierervice = (Supplierervice) context.getBean("supplierervice");
        List<Supplier> suppliers = supplierervice.selectAll();
        for (Supplier supplier : suppliers) {
            System.out.println(supplier);
        }
    }

    @Test
    public void selectBySupName() {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext3.xml");
        Supplierervice supplierervice = (Supplierervice) context.getBean("supplierervice");
        List<Supplier> suppliers = supplierervice.selectBySupName("巧克力");
        for (Supplier supplier : suppliers) {
            System.out.println(supplier);
        }
    }

    @Test
    public void insertBatch() {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext3.xml");
        Supplierervice supplierservice = (Supplierervice) context.getBean("supplierervice");
        Supplier supplier1 = new Supplier("S17","郴州天河软件开发责任有限公司","侯慧聪开的公司","侯慧聪","17773572868","北湖区天星公园1号");
        Supplier supplier2 = new Supplier("S18","郴州天龙软件开发责任有限公司","侯天龙开的公司","侯天龙","17773572888","北湖区天龙公园1号");
        int i = supplierservice.saveBatch(Arrays.asList(supplier1, supplier2));
        System.out.println(i);
    }
}